{extend name="public/common"/}
{block name="head"}

{/block}

{block name="banner"}

<div class="banner">
    <div class="wrapper">
        <div class="txt">
            {$category.title}
        </div>
    </div>
</div>
{/block}
{block name="body"}
{include file="document/nav"/}
<div class="wrapper newslist">
    <div class="newslist-bd" style="min-height:300px">
        <input type="hidden" name="page" id="page" value="1">
        <ul id="lists">
            {Cms:document name="document" category_id="$category['id']" row="6"}

            <li>
                <a href="{:url('cms/Document/detail?category_id='.$document['category_id'],['id'=>$document['id']])}" title="{$document.title}">
                    <div class="img">
                        <img src="{$docuemtn.cover.url|default='__IMG__/default_img.jpg'}" onerror="src='__IMG__/default_img.jpg'"/>
                    </div>
                    <div class="txt">
                        <div class="txt-hd">{$document.title}</div>
                        <div class="txt-bd">{$document.description}
                        </div>
                        <div class="txt-ft">
                            <div class="left">
                                <span>{$document.create_time}</span>
                            </div>
                            <div class="right">
                                &gt;&gt;
                            </div>
                        </div>
                    </div>
                </a>
            </li>
            {/Cms:document}
        </ul>
    </div>
    <div class="newslist-ft" id="getmore">
        <a class="g-btn" href="javascript:;">加载更多</a>
    </div>
</div>
{/block}


{block name="script"}

<script type="text/javascript">
    $("#getmore").click(function(){
        var page = $("#page").val();
        $.ajax({
            type: "get",
            dataType: "json",
            url: "{:url('cms/Document/lists?category_id='.$category['id'])}",
            data: {pageCurrent:parseInt(page) + 1,more:1},
            success: function(result) {
                if(0 == result.code && result.data.data.length>0) {
                    var str = "";
                    $.each(result.data.data,function(index,array){
                            if(!array['title_img']) {
                                array['title_img'] = '__IMG__/default_img.jpg';
                            }
                            str += '<li>';
                            str += '<a href="{:url(\'index/Document/detail\',[],false,false)}/'+array['id']+'">';
                            str += '<div class="img">';
                            str += '<img src="'+array['title_img']+'"/></div>';
                            str += '<div class="txt">';
                            str += '<div class="txt-hd">';
                            str += array['title'];
                            str += '</div>';
                            str += '<div class="txt-bd">'+array['description']+'</div>';
                            str += '<div class="txt-ft"> <div class="left">';
                            str += '<span>'+array['create_time']+'</span>';
                            str += '</div><div class="right">  &gt;&gt;</div> </div></div></a></li>';
                    });
                    $("#lists").append(str);
                    if (result.data.current_page >= result.data.last_page)
                    {
                        $("#getmore").html("没有更多内容了..");
                    }
                    $("#page").val(result.data.current_page);
                } else {
                    $("#getmore").html("没有更多内容了..");
                }
            }
        });
    });
</script>
{/block}
